package com.rfid.a252robot.base;

import android.app.Activity;
import android.hardware.usb.UsbDevice;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseListActivity <T extends BaseAdapter,Y,G extends BasePresenter> extends BaseActivity<G> implements Listener<Y>  {

    protected RecyclerView mRecyclerView;
    protected T mAdapter;
    protected Listener<Y> mListener;
    protected List<Y> mData = new ArrayList<>();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResId());
        mAdapter = getAdapter();
        mAdapter.setListener(this);
        mRecyclerView = findViewById(getRecyclerViewId());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setAdapter(mAdapter);
    }

    protected abstract int getLayoutResId();

    protected abstract T getAdapter();

    protected abstract int getRecyclerViewId();

}
